package net.ncraft.mc.ezframework.core.gui.einventory;

import lombok.Getter;
import lombok.Setter;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class InvElement {
    @Getter
    @Setter
    private EInventory inventory;
    @Getter
    @Setter
    private int slot;
    @Getter
    @Setter
    private ItemStack itemStack;
    @Getter
    @Setter
    private int priority = 100;
    @Getter
    @Setter
    private InvAction onClick;
    @Getter
    private Setter displayName;
    @Getter
    @Setter
    private InvElementType eleType = InvElementType.VAR;

    public InvElement(int slot, ItemStack itemStack) {
        this(slot, itemStack, (i, p) -> {});
    }

    public InvElement(int slot, ItemStack itemStack, InvAction onClick) {
        this.slot = slot;
        this.itemStack = itemStack;
        this.onClick = onClick;
    }

    public void onClick() {
        onClick.run(inventory, inventory.getPlayer());
    }

    public void setDisplayName(String displayName) {
        ItemMeta itemMeta = this.itemStack.getItemMeta();
        itemMeta.setDisplayName(displayName);
        this.itemStack.setItemMeta(itemMeta);
    }

}
